import home from '@/api/home'

import {
  GET_USERINFO,
  SAVE_ADDRESS
} from './mutation-types.js'

export default {
  async getUserInfo ({
    commit,
    state
  }) {
    let res = await home.getUser()
    commit(GET_USERINFO, res.data)
  },
  async saveAddress ({
    commit,
    state
  }) {
    if (state.removeAddress.length > 0) return
    let address = await home.getAddressList(state.userInfo.user_id)
    commit(SAVE_ADDRESS, address)
  }
}
